package cn.lili.modules.goods.entity.dto;

import cn.hutool.core.util.StrUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsHotPopular;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class GoodsHotPopularDTO extends PageVO {

    /**
     * 店铺ID
     */
    private String storeId;

    /**
     * 店铺名称
     */
    private String storeName;

    /**
     * 原价
     */
    private Double originalPrice;

    /**
     * 结算价格
     */
    private Double settlementPrice;

    /**
     * 缩略图
     */
    private String thumbnail;

    /**
     * 商品编号
     */
    private String goodsId;

    /**
     * 商品名称
     */
    private String goodsName;

    /**
     * 排序
     */
    private Integer sortNum;

    /**
     * 商品分类路径
     */
    private String categoryPath;


    public LambdaQueryWrapper<GoodsHotPopular> toQueryWrapper() {
        LambdaQueryWrapper<GoodsHotPopular> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotEmpty(goodsId), GoodsHotPopular::getGoodsId, goodsId);
        queryWrapper.likeRight(StrUtil.isNotEmpty(goodsName), GoodsHotPopular::getGoodsName, goodsName);
        queryWrapper.eq(StrUtil.isNotEmpty(storeId), GoodsHotPopular::getStoreId, storeId);
        queryWrapper.likeRight(StrUtil.isNotEmpty(storeName), GoodsHotPopular::getStoreName, storeName);
        queryWrapper.orderByAsc(GoodsHotPopular::getSortNum).orderByDesc(GoodsHotPopular::getUpdateTime).orderByDesc(GoodsHotPopular::getId);
        return queryWrapper;
    }
}
